#include<bits/stdc++.h>
int a[200005],f[200005];
using namespace std;
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int T;
    cin>>T;
    while(T--){
        int n;
        cin>>n;
        int sum=0;
        memset(f,0,sizeof(f));
        for(int i=1;i<=n;i++){
            cin>>a[i];
            if(f[a[i]]==0) f[a[i]]=1;
            else if(f[a[i]]==1){
                sum+=a[i];
                f[a[i]]=-1;
            }
        }
        cout<<sum<<endl;
    }
    return 0;
}